require(['./config'],()=>{
    require(['swiper','template','header','footer'],(Swiper,template)=>{
        class Index{
            constructor(){
                this.banner()
                this.getHotList()
                this.getGoodsList()
                this.getFunctionList()
                this.getFemaleList()
                this.getClassicList()
                this.getHomeTitle()
            }
            banner(){
                var mySwiper = new Swiper ('.swiper-container', {
                    loop: true, // 循环模式选项
                    autoplay:true,
                    effect : 'fade',
                    
                    // 如果需要分页器
                    pagination: {
                      el: '.swiper-pagination',
                    },
                    
                    // 如果需要前进后退按钮
                    navigation: {
                      nextEl: '.swiper-button-next',
                      prevEl: '.swiper-button-prev'
                    }
                })  
            }
            getHotList(){
                $.get('http://rap2.taobao.org:38080/app/mock/264809/api/list/shop',resp=>{
                    if(resp.code===200){
                        let {list}=resp.body
                        list=list.slice(0,6)
                        $('#hotList').html(template('hotListTemplate',{list}))
                    }

                })
            }
            getGoodsList(){
                $.get('http://rap2.taobao.org:38080/app/mock/264809/api/list/shop',resp=>{
                    if(resp.code===200){
                        let {list}=resp.body
                        list=list.slice(1,9)
                        $('#basicsgoodsList').html(template('basicsListTemplate',{list}))
                    }
                })
            }
            getFunctionList(){
                $.get('http://rap2.taobao.org:38080/app/mock/264809/api/list/shop',resp=>{
                    if(resp.code===200){
                        let {list}=resp.body
                        list=list.slice(9,17)
                        $('#functionList').html(template('functionListTemplate',{list}))
                    }
                })
            }
            getFemaleList(){
                $.get('http://rap2.taobao.org:38080/app/mock/264809/api/list/shop',resp=>{
                    if(resp.code===200){
                        let {list}=resp.body
                        list=list.slice(17,25)
                        $('#femaleList').html(template('femaleListTemplate',{list}))
                    }
                })
            }
            getClassicList(){
                $.get('http://rap2.taobao.org:38080/app/mock/264809/api/list/shop',resp=>{
                    if(resp.code===200){
                        let {list}=resp.body
                        list=list.slice(25,33)
                        $('#classicList').html(template('classicListTemplate',{list}))
                    }
                })
            }
            getHomeTitle(){
                $.get('http://www.xiongmaoyouxuan.com/api/tabs',resp=>{
                    if(resp.code===200){
                        let {list}=resp.data
                        list=list.slice(1,12)
                        $('#bannerTitle').html(template('bannerTitleTemplate',{list}))
                    }
                })
            }
        }
        new Index()
    })
})